import { defineConfig } from "vite";
import { resolve } from "path";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  build: {
    rollupOptions: {
      input: {
        main: "./src/main.js",
        check: "./src/checkin.js",
      },
    },
  },
  resolve: {
    alias: [
      {
        find: "@",
        replacement: resolve(__dirname, "./src"),
      },
      {
        find: "assets",
        replacement: resolve(__dirname, "./src/assets"),
      },
    ],
    extensions: [".ts", ".js"],
  },
  css: {
    preprocessorOptions: {
      css: {
        // 预处理器配置项
        preprocessorOptions: {
          less: {
            math: "always",
            globalVars: {
              fontSizeNormal: "16px",
              baseBgColor: "#f9f9f9",
            },
          },
        },
      },
    },
  },
  server: {
    // 配置服务器代理，实现跨域
    // https: true,
    port: 3002,
    proxy: {
      "/crewService": {
        target: "http://localhost:8081/",
        changeOrigin: true,
        //去掉接口中的 '/api'以便和后端接口匹配
        // rewrite: (path) => path.replace(/^\/api/, ""),
      },
      // "/videoConfig": {
      //   target: "https://192.168.101.253:443/",
      //   changeOrigin: true,
      //   secure: true,
      //   //去掉接口中的 '/api'以便和后端接口匹配
      //   rewrite: (path) => path.replace(/^\/videoConfig/, ""),
      // },
    },
  },
});
